package com.masterclient.app.businessmodule.homemodule.view.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.ViewGroup;

import com.alibaba.android.vlayout.DelegateAdapter;
import com.alibaba.android.vlayout.VirtualLayoutManager;
import com.alibaba.android.vlayout.layout.LinearLayoutHelper;
import com.alibaba.android.vlayout.layout.SingleLayoutHelper;
import com.eoner.commonbean.banner.BannerNewItemBean;
import com.masterclient.app.R;
import com.masterclient.app.businessmodule.homemodule.bean.banner.BannerNewBean;
import com.masterclient.app.businessmodule.homemodule.bean.banner.SpecialImagBean;
import com.masterclient.app.businessmodule.homemodule.bean.footertab.HomeFooterTabBean;
import com.masterclient.app.businessmodule.homemodule.bean.homecms.HomeCmsIndexBean;
import com.masterclient.app.businessmodule.homemodule.bean.homecms.HomeNewCmsIndexBean;
import com.masterclient.app.businessmodule.homemodule.bean.hot.HotSearchWordBean;
import com.masterclient.app.businessmodule.homemodule.bean.saletabs.FlashSaleTabBean;
import com.masterclient.app.businessmodule.homemodule.bean.shoplist.ProductHomeMessage;
import com.masterclient.app.businessmodule.homemodule.old.EventAdDataCallback;
import com.masterclient.app.businessmodule.homemodule.view.adapter.banner.PageXBannerAdapter;
import com.masterclient.app.businessmodule.homemodule.view.adapter.capsules.HomePageXTemporaryAdapter;
import com.masterclient.app.businessmodule.homemodule.view.adapter.diamond.HomePageXDiamondZoneAdapter;
import com.masterclient.app.businessmodule.homemodule.view.adapter.feature.HomePageTowPicAdapter;
import com.masterclient.app.businessmodule.homemodule.view.adapter.feature.HomePageXFeatureAdapter;
import com.masterclient.app.businessmodule.homemodule.view.adapter.firstorcelains.HomePageXAdThreeAdapter;
import com.masterclient.app.businessmodule.homemodule.view.adapter.footer.HomePageFooterTitleAdapter;
import com.masterclient.app.businessmodule.homemodule.view.adapter.footer.HomePageXFootStickAdapter;
import com.masterclient.app.businessmodule.homemodule.view.adapter.gradual.HomePageXGradualZoneAdapter;
import com.masterclient.app.businessmodule.homemodule.view.adapter.liveone.HomePageLiveOneAdAdapter;
import com.masterclient.app.businessmodule.homemodule.view.adapter.livetwo.HomePageLiveTwoAdAdapter;
import com.masterclient.app.businessmodule.homemodule.view.adapter.promotions.HomePageXAdGroupAdapter;
import com.masterclient.app.businessmodule.homemodule.view.adapter.recommand.HomePageNewXFootContentAdapter;
import com.masterclient.app.businessmodule.homemodule.view.adapter.saletab.HomePageXTimeLimitedHeadAdapter;
import com.masterclient.app.businessmodule.homemodule.view.adapter.special.HomePageXRemAdapter;
import com.masterclient.app.businessmodule.homemodule.view.adapter.template.HomePageFooterAdapter;
import com.masterclient.app.businessmodule.homemodule.view.adapter.template.HomePageXCollectionAdapter;
import com.masterclient.app.businessmodule.homemodule.view.adapter.threeporcelain.HomePageXAdGridlayoutAdapter;
import com.masterclient.app.businessmodule.homemodule.view.holder.HomeViewHolder;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;


public class HomeRecycleAdapterGroup extends DelegateAdapter implements EventAdDataCallback {

    private final List<Adapter> adapters = new LinkedList<>();
    //adapters
    private PageXBannerAdapter bannerAdapter;
    private HomePageXFeatureAdapter homePageXFeatureAdapter;
    private HomePageXDiamondZoneAdapter homePageXDiamondZoneAdapter;
    private HomePageTowPicAdapter homePageTowPicAdapter;
    private HomePageXTemporaryAdapter homePageXTemporaryAdapter;
    private HomePageXAdGroupAdapter homePageXAdGroupAdapter;
    private HomePageXGradualZoneAdapter homePageXGradualZoneAdapter;
    private HomePageXAdThreeAdapter homePageXAdThreeAdapter;
    private HomePageLiveOneAdAdapter homePageLiveOneAdAdapter;
    private HomePageXAdGridlayoutAdapter homePageXAdGridlayoutAdapter;
    private HomePageLiveTwoAdAdapter homePageLiveTwoAdAdapter;
    private HomePageXTimeLimitedHeadAdapter homePageXTimeLimitedHeadAdapter;
    private HomePageXCollectionAdapter homePageXCollectionAdapter;
    private HomePageXRemAdapter homePageXRemAdapter;
    private HomePageXFootStickAdapter homePageXFootStickAdapter;
    private HomePageFooterTitleAdapter homePageFooterTitleAdapter;
    private HomePageNewXFootContentAdapter homePageXFootContentAdapter;
    private HomePageFooterAdapter homePageFooterAdapter;
    //listener
    private HomeRecycleAdapterGroupListener iHomeRecycleAdapterGroupListener;

    public void setHomeRecycleAdapterGroupListener(HomeRecycleAdapterGroupListener iHomeRecycleAdapterGroupListener) {
        this.iHomeRecycleAdapterGroupListener = iHomeRecycleAdapterGroupListener;
    }

    public HomeRecycleAdapterGroup(VirtualLayoutManager layoutManager) {
        super(layoutManager);
    }

    public HomeRecycleAdapterGroup(VirtualLayoutManager layoutManager, boolean hasConsistItemType) {
        super(layoutManager, hasConsistItemType);
    }

    /**
    * 清空adapters
    * */
    public void clearAdapters() {
        adapters.clear();
        setAdapters(adapters);
    }

    /**
    * footertab 吸顶
    * */
    public void setFooterTabState(int state) {
        if (homePageXFootStickAdapter != null) {
            homePageXFootStickAdapter.set_tab_bkg(state);
        }
    }

    /**
    * 首页列表-添加banner adapter
    * */
    public boolean homeDataToAddBannerAdapter(Context mContext, List<HotSearchWordBean> hotSearchWordBeanList, BannerNewBean bannerBean) {
        if (adapters.contains(bannerAdapter)) {
            bannerAdapter.stopAutoPlay();
            adapters.remove(bannerAdapter);
        }
        if (bannerBean != null && bannerBean.getList() != null && bannerBean.getList().size() >0) {
            SingleLayoutHelper layoutHelper = new SingleLayoutHelper();
            bannerAdapter = new PageXBannerAdapter(mContext, layoutHelper, 1, null, bannerBean, hotSearchWordBeanList, new PageXBannerAdapter.ColorCallBack() {
                @Override
                public void color_change(int color) {
                    if (iHomeRecycleAdapterGroupListener != null) {
                        iHomeRecycleAdapterGroupListener.homeAdapterToBannerColorChange(color);
                    }
                }
            }) {
                @Override
                public HomeViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
                    return new HomeViewHolder(LayoutInflater.from(mContext).inflate(R.layout.home_new_page_x_banner, parent, false));
                }

                @Override
                public void onBindViewHolder(HomeViewHolder holder, int position) {
                    super.onBindViewHolder(holder, position);
                }
            };
            bannerAdapter.setEventAdDataCallback(this);
            adapters.add(bannerAdapter);
            return true;
        }
        return false;
    }

    /**
    * 首页列表 - 正品广告
    * */
    public boolean homeDataToAddFeatureAdapter(Context mContext, BannerNewBean bannerBean) {

//        if (adapters.contains(homePageXFeatureAdapter)) {
//            adapters.remove(homePageXFeatureAdapter);
//        }
//        if (bannerBean != null) {
//            SingleLayoutHelper layoutHelper = new SingleLayoutHelper();
//            homePageXFeatureAdapter = new HomePageXFeatureAdapter(mContext, layoutHelper, 1, null, bannerBean) {
//                @Override
//                public HomeViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
//                    return new HomeViewHolder(LayoutInflater.from(mContext).inflate(R.layout.home_page_x_feature, parent, false));
//                }
//
//                @Override
//                public void onBindViewHolder(HomeViewHolder holder, int position) {
//                    super.onBindViewHolder(holder, position);
//                }
//            };
//            homePageXFeatureAdapter.setEventAdDataCallback(this);
//            adapters.add(homePageXFeatureAdapter);
//            return true;
//        }
        return false;
    }

    /**
    * 首页列表 - 固定两张占位图片
    * */
    public boolean homeDataToAddTowPicAdapter(Context mContext, SpecialImagBean bannerBean) {

        if (adapters.contains(homePageTowPicAdapter)) {
            adapters.remove(homePageTowPicAdapter);
        }
        if (bannerBean != null) {
            SingleLayoutHelper layoutHelper = new SingleLayoutHelper();
            homePageTowPicAdapter = new HomePageTowPicAdapter(mContext, layoutHelper, 1, null, bannerBean) {
                @Override
                public HomeViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
                    return new HomeViewHolder(LayoutInflater.from(mContext).inflate(R.layout.home_page_two_pic, parent, false));
                }

                @Override
                public void onBindViewHolder(HomeViewHolder holder, int position) {
                    super.onBindViewHolder(holder, position);
                }
            };
            homePageTowPicAdapter.setEventAdDataCallback(this);
            adapters.add(homePageTowPicAdapter);
            return true;
        }
        return false;
    }

    /**
    * 金刚区
    * */
    public boolean homeDataToAddDiamondsAdapter(Context mContext,BannerNewBean diamonds) {
        //金刚区

        if (adapters.contains(homePageXDiamondZoneAdapter)) {
            adapters.remove(homePageXDiamondZoneAdapter);
        }
        if (diamonds != null && diamonds.getList() != null && diamonds.getList().size() > 0) {
            SingleLayoutHelper layoutHelper = new SingleLayoutHelper();
            homePageXDiamondZoneAdapter = new HomePageXDiamondZoneAdapter(mContext, layoutHelper, 1, null, diamonds) {
                @Override
                public HomeViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
                    return new HomeViewHolder(LayoutInflater.from(mContext).inflate(R.layout.home_page_x_diamond_zone, parent, false));
                }

                @Override
                public void onBindViewHolder(HomeViewHolder holder, int position) {
                    super.onBindViewHolder(holder, position);
                }
            };
            homePageXDiamondZoneAdapter.setEventAdDataCallback(this);
            adapters.add(homePageXDiamondZoneAdapter);
            return true;
        }
        return false;
    }

    /**
    * 首页胶囊区
    * */
    public boolean homeDataToAddCapsulesAdapter(Context mContext,List<BannerNewItemBean>capsules) {
        if (adapters.contains(homePageXTemporaryAdapter)) {
            adapters.remove(homePageXTemporaryAdapter);
        }
        if (capsules != null) {
            SingleLayoutHelper layoutHelper = new SingleLayoutHelper();
            homePageXTemporaryAdapter = new HomePageXTemporaryAdapter(mContext, layoutHelper, 1, null, capsules) {
                @Override
                public HomeViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
                    return new HomeViewHolder(LayoutInflater.from(mContext).inflate(R.layout.home_page_x_temporary, parent, false));
                }

                @Override
                public void onBindViewHolder(HomeViewHolder holder, int position) {
                    super.onBindViewHolder(holder, position);
                }
            };
            homePageXTemporaryAdapter.setEventAdDataCallback(this);
            adapters.add(homePageXTemporaryAdapter);
            return true;
        }
        return false;
    }

    /**
    * 大促区
    * */
    public boolean homeDataToAddPromotionsAdapter(Context context,BannerNewBean promotions) {
        //大促区
        if (adapters.contains(homePageXAdGroupAdapter)) {
            adapters.remove(homePageXAdGroupAdapter);
        }
        if (promotions != null && promotions.getList() != null) {
            SingleLayoutHelper layoutHelper = new SingleLayoutHelper();
            homePageXAdGroupAdapter = new HomePageXAdGroupAdapter(context, layoutHelper, 1, null, promotions) {
                @Override
                public HomeViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
                    if (promotions.getList().size()== 1){
                        return new HomeViewHolder(LayoutInflater.from(context).inflate(R.layout.home_page_dc_one_pic, parent, false));
                    }else if (promotions.getList().size()== 2){
                        return new HomeViewHolder(LayoutInflater.from(context).inflate(R.layout.home_page_dc_two_pic, parent, false));
                    }else if (promotions.getList().size()== 3){
                        return new HomeViewHolder(LayoutInflater.from(context).inflate(R.layout.home_page_dc_three_pic, parent, false));
                    }else if (promotions.getList().size()== 4){
                        return new HomeViewHolder(LayoutInflater.from(context).inflate(R.layout.home_page_dc_four_pic, parent, false));
                    }else if (promotions.getList().size()== 5){
                        return new HomeViewHolder(LayoutInflater.from(context).inflate(R.layout.home_page_dc_five_pic, parent, false));
                    }else {
                        return new HomeViewHolder(LayoutInflater.from(context).inflate(R.layout.home_page_dc_one_pic, parent, false));
                    }
                }

                @Override
                public void onBindViewHolder(HomeViewHolder holder, int position) {
                    super.onBindViewHolder(holder, position);
                }
            };
            homePageXAdGroupAdapter.setEventAdDataCallback(this);
            adapters.add(homePageXAdGroupAdapter);
            return true;
        }
        return false;
    }

    /**
    * 分割线
    * */
    public boolean homeDataToGradualZoneAdapter(Context context) {
        //渐变分割线
        if (adapters.contains(homePageXGradualZoneAdapter)) {
            adapters.remove(homePageXGradualZoneAdapter);
        }

        if (true) {
            SingleLayoutHelper layoutHelper = new SingleLayoutHelper();
            homePageXGradualZoneAdapter = new HomePageXGradualZoneAdapter(context, layoutHelper, 1, null) {
                @Override
                public HomeViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
                    return new HomeViewHolder(LayoutInflater.from(context).inflate(R.layout.home_page_x_gradual_zone, parent, false));
                }

                @Override
                public void onBindViewHolder(HomeViewHolder holder, int position) {
                    super.onBindViewHolder(holder, position);
                }
            };
            adapters.add(homePageXGradualZoneAdapter);
            return true;
        }
        return false;
    }

    /**
    * 新三张图一排
    * */
    public boolean homeDataToFirstPorcelainsAdapter(Context context,List<BannerNewItemBean>firstPorcelains) {
        if (adapters.contains(homePageXAdThreeAdapter)) {
            adapters.remove(homePageXAdThreeAdapter);
        }
        if (firstPorcelains != null) {
            SingleLayoutHelper layoutHelper = new SingleLayoutHelper();
            homePageXAdThreeAdapter = new HomePageXAdThreeAdapter(context, layoutHelper, 1, null, firstPorcelains) {
                @Override
                public HomeViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
                    return new HomeViewHolder(LayoutInflater.from(context).inflate(R.layout.home_page_x_ad_gridlayout, parent, false));
                }

                @Override
                public void onBindViewHolder(HomeViewHolder holder, int position) {
                    super.onBindViewHolder(holder, position);
                }
            };
            homePageXAdThreeAdapter.setEventAdDataCallback(this);
            adapters.add(homePageXAdThreeAdapter);
            return true;
        }
        return false;
    }

    /**
    * 直播广告位1
    * */
    public boolean homeDataToSecondLiveOneAdAdapter(Context context,List<BannerNewItemBean>secondPorcelains) {
        if (adapters.contains(homePageLiveOneAdAdapter)) {
            adapters.remove(homePageLiveOneAdAdapter);
        }
        if (secondPorcelains != null && secondPorcelains.size() > 0) {
            SingleLayoutHelper layoutHelper = new SingleLayoutHelper();
            homePageLiveOneAdAdapter = new HomePageLiveOneAdAdapter(context, layoutHelper, 1, null, secondPorcelains) {
                @Override
                public HomeViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
                    return new HomeViewHolder(LayoutInflater.from(context).inflate(R.layout.home_page_live_ad_item, parent, false));
                }

                @Override
                public void onBindViewHolder(HomeViewHolder holder, int position) {
                    super.onBindViewHolder(holder, position);
                }
            };
            adapters.add(homePageLiveOneAdAdapter);
            return true;
        }
        return false;
    }

    /**
    * 网格广告
    * */
    public boolean homeDataToThreePorcelainAdapter(Context context,List<BannerNewItemBean> threePorcelains) {
        //网格广告
        if (adapters.contains(homePageXAdGridlayoutAdapter)) {
            adapters.remove(homePageXAdGridlayoutAdapter);
        }
        if (threePorcelains != null && threePorcelains.size() > 0) {
            Iterator<BannerNewItemBean> iterator = threePorcelains.iterator();
            while (iterator.hasNext()) {
                BannerNewItemBean temp = iterator.next();
                if (temp == null) {
                    iterator.remove();//使用迭代器的删除方法删除
                }
            }
        }
        if (threePorcelains != null) {
            SingleLayoutHelper layoutHelper = new SingleLayoutHelper();
            homePageXAdGridlayoutAdapter = new HomePageXAdGridlayoutAdapter(context, layoutHelper, 1, null, threePorcelains) {
                @Override
                public HomeViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
                    return new HomeViewHolder(LayoutInflater.from(context).inflate(R.layout.home_page_x_ad_gridlayout, parent, false));
                }

                @Override
                public void onBindViewHolder(HomeViewHolder holder, int position) {
                    super.onBindViewHolder(holder, position);
                }
            };
            homePageXAdGridlayoutAdapter.setEventAdDataCallback(this);
            adapters.add(homePageXAdGridlayoutAdapter);
            return true;
        }
        return false;
    }

    /**
     * 直播模块2
     * */
    public boolean homeDataToFourthLiveTwoAdAdapter(Context context,List<BannerNewItemBean>fourthPorcelains) {
        //直播广告位2
        if (adapters.contains(homePageLiveTwoAdAdapter)) {
            adapters.remove(homePageLiveTwoAdAdapter);
        }
        if (fourthPorcelains != null && fourthPorcelains.size() > 0) {
            SingleLayoutHelper layoutHelper = new SingleLayoutHelper();
            homePageLiveTwoAdAdapter = new HomePageLiveTwoAdAdapter(context, layoutHelper, 1, null, fourthPorcelains) {
                @Override
                public HomeViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
                    return new HomeViewHolder(LayoutInflater.from(context).inflate(R.layout.home_page_live_ad_item, parent, false));
                }

                @Override
                public void onBindViewHolder(HomeViewHolder holder, int position) {
                    super.onBindViewHolder(holder, position);
                }
            };
            adapters.add(homePageLiveTwoAdAdapter);
            return true;
        }
        return false;
    }

    /**
     * 限时购
     * */
    public boolean homeDataToSaleTabAdapter(Context context,List<FlashSaleTabBean>flashSaleTabBeans) {
        //限时购的倒计时
        if (adapters.contains(homePageXTimeLimitedHeadAdapter)) {
            adapters.remove(homePageXTimeLimitedHeadAdapter);
        }
        if (flashSaleTabBeans != null && flashSaleTabBeans.size() > 0) {
            SingleLayoutHelper layoutHelper = new SingleLayoutHelper();
            if (homePageXTimeLimitedHeadAdapter == null) {
                homePageXTimeLimitedHeadAdapter = new HomePageXTimeLimitedHeadAdapter(context, layoutHelper, 1, null, flashSaleTabBeans) {
                    @Override
                    public HomeViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
                        return new HomeViewHolder(LayoutInflater.from(context).inflate(R.layout.home_page_x_time_limited_head, parent, false));
                    }

                    @Override
                    public void onBindViewHolder(HomeViewHolder holder, int position) {
                        super.onBindViewHolder(holder, position);
                    }
                };
            } else {
                homePageXTimeLimitedHeadAdapter.refreshData(flashSaleTabBeans);
            }
            homePageXTimeLimitedHeadAdapter.initCountDownTimer();
            homePageXTimeLimitedHeadAdapter.setOnClickStatusListener(new HomePageXTimeLimitedHeadAdapter.OnClickStatusListener() {
                @Override
                public void clickStatusBtn(String type, String productId, String mapId, int childPosition, String startTime) {
                    if (iHomeRecycleAdapterGroupListener != null) {
                        iHomeRecycleAdapterGroupListener.homeAdapterToSaleTabEvents(type,productId,mapId,childPosition,startTime);
                    }
                }

                @Override
                public void onClickTab(String mapId, int selIndex,String status) {
                    if (iHomeRecycleAdapterGroupListener != null) {
                        iHomeRecycleAdapterGroupListener.homeAdapterToClickSaleTab(mapId,selIndex,status);
                    }
                }

                @Override
                public void onRefreshData() {
                    if (iHomeRecycleAdapterGroupListener != null) {
                        iHomeRecycleAdapterGroupListener.homeAdapterToRefreshSale();
                    }
                }
            });
            adapters.add(homePageXTimeLimitedHeadAdapter);
            return true;
        }
        return false;
    }

    public void homeDataToRefreshSaleTabAdapter(List<FlashSaleTabBean>flashSaleTabBeans) {
        if (homePageXTimeLimitedHeadAdapter != null) {
            homePageXTimeLimitedHeadAdapter.refreshAll(1,flashSaleTabBeans);
            homePageXTimeLimitedHeadAdapter.initCountDownTimer();
        }
    }

    /**
    * 刷新限时购
    * */
    public void homeDataToRefreshSaleTabAdapter(List<FlashSaleTabBean>flashSaleTabBeans,int selIndex,String status) {
        if (homePageXTimeLimitedHeadAdapter != null) {
            homePageXTimeLimitedHeadAdapter.refreshChildData(flashSaleTabBeans,status);
        }
    }

    /**
    *  为你精选
    * */
    public boolean homeDataToTemplateCmsAdapter(Context context, String brand_list_url,List<HomeNewCmsIndexBean> templateCmsData) {
        if (adapters.contains(homePageXCollectionAdapter)) {
            adapters.remove(homePageXCollectionAdapter);
        }
        if (templateCmsData != null && templateCmsData.size() >0) {
            SingleLayoutHelper layoutHelper = new SingleLayoutHelper();
            homePageXCollectionAdapter = new HomePageXCollectionAdapter(context, layoutHelper, 1, null, brand_list_url,templateCmsData) {
                @Override
                public HomeViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
                    return new HomeViewHolder(LayoutInflater.from(context).inflate(R.layout.home_page_x_collection, parent, false));
                }

                @Override
                public void onBindViewHolder(HomeViewHolder holder, int position) {
                    super.onBindViewHolder(holder, position);
                }
            };
            adapters.add(homePageXCollectionAdapter);
            return true;
        }
        return false;

    }

    /**
     *  专题精选
     * */
    public boolean homeDataToSpecialCmsAdapter(Context context, HomeCmsIndexBean specialCmsData) {
        if (adapters.contains(homePageXRemAdapter)) {
            adapters.remove(homePageXRemAdapter);
        }
        if (specialCmsData != null) {
            SingleLayoutHelper layoutHelper = new SingleLayoutHelper();
            homePageXRemAdapter = new HomePageXRemAdapter(context, layoutHelper, 1, null, specialCmsData) {
                @Override
                public HomeViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
                    return new HomeViewHolder(LayoutInflater.from(context).inflate(R.layout.home_page_x_rem, parent, false));
                }

                @Override
                public void onBindViewHolder(HomeViewHolder holder, int position) {
                    super.onBindViewHolder(holder, position);
                }
            };
            adapters.add(homePageXRemAdapter);
            return true;
        }
        return false;
    }

    public HomePageFooterAdapter getHomePageFooterAdapter(){
        return homePageFooterAdapter;
    }

    /**
    * 底部商品列表
    * */
    public boolean homeDataToFooterClassAdapter(Context context, List<ProductHomeMessage>list) {
        //底部分类列表
        if (adapters.contains(homePageFooterAdapter)) {
            adapters.remove(homePageFooterAdapter);
        }
        if (list != null) {
            SingleLayoutHelper layoutHelper = new SingleLayoutHelper();
                homePageFooterAdapter = new HomePageFooterAdapter(context, layoutHelper,1, null,list) {
                    @Override
                    public HomeViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
                        return new HomeViewHolder(LayoutInflater.from(context).inflate(R.layout.home_page_footer_recycler, parent, false));
                    }

                    @Override
                    public void onBindViewHolder(HomeViewHolder holder, int position) {
                        super.onBindViewHolder(holder, position);
                    }
                };
                adapters.add(homePageFooterAdapter);
            return true;
        }
        return false;
    }

    /**
     * 处理底部title
     * */
    public boolean homeDataFooterTitle(Context mContext) {
        if (adapters.contains(homePageFooterTitleAdapter)) {
            adapters.remove(homePageFooterTitleAdapter);
        }
        SingleLayoutHelper layoutHelper = new SingleLayoutHelper();
        homePageFooterTitleAdapter = new HomePageFooterTitleAdapter(mContext, layoutHelper, 1, null) {
            @Override
            public HomeViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
                return new HomeViewHolder(LayoutInflater.from(mContext).inflate(R.layout.home_page_footer_title, parent, false));
            }

            @Override
            public void onBindViewHolder(HomeViewHolder holder, int position) {
                super.onBindViewHolder(holder, position);
            }
        };
        homePageFooterTitleAdapter.setEventAdDataCallback(this);
        adapters.add(homePageFooterTitleAdapter);
        return true;
    }


    /**
     * 刷新商品列表
     * */
    public void homeDataToFooterShopList(Context context,List<HomeFooterTabBean>tabBeanList) {
        if (adapters.contains(homePageXFootContentAdapter)) {
            adapters.remove(homePageXFootContentAdapter);
        }
        if (tabBeanList != null) {
            LinearLayoutHelper layoutHelper = new LinearLayoutHelper();
            homePageXFootContentAdapter = new HomePageNewXFootContentAdapter(context, layoutHelper,tabBeanList,1, null) {
                @Override
                public HomeViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
                    return new HomeViewHolder(LayoutInflater.from(context).inflate(R.layout.home_page_new_x_foot_content, parent, false));
                }

                @Override
                public void onBindViewHolder(HomeViewHolder holder, int position) {
                    super.onBindViewHolder(holder, position);
                }
            };
            adapters.add(homePageXFootContentAdapter);
        }
    }

//    /**
//    * 刷新商品列表
//    * */
//    public void homeDataToFooterShopList(Context context,HomeFooterTabBean homeFooterTabBean) {
//        if (adapters.contains(homePageXFootContentAdapter)) {
//            adapters.remove(homePageXFootContentAdapter);
//        }
//        if (homeFooterTabBean != null) {
//            LinearLayoutHelper layoutHelper = new LinearLayoutHelper();
//            homePageXFootContentAdapter = new HomePageXFootContentAdapter(context, layoutHelper, 1, null,homeFooterTabBean) {
//                @Override
//                public HomeViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
//                    return new HomeViewHolder(LayoutInflater.from(context).inflate(R.layout.home_page_x_foot_content, parent, false));
//                }
//
//                @Override
//                public void onBindViewHolder(HomeViewHolder holder, int position) {
//                    super.onBindViewHolder(holder, position);
//                }
//            };
//            adapters.add(homePageXFootContentAdapter);
//        }
//    }

//    /**
//    * 加载更多商品列表
//    * */
//    public void homeDataToLoadMoreShopList(List<ProductMessage>list,int rangeStart) {
//        if (homePageXFootContentAdapter != null) {
//            homePageXFootContentAdapter.addData(list,rangeStart);
//        }
//    }

    /**
     * 加载更多商品列表
     * */
    public void homeDataToLoadMoreShopList(Context context,int index,List<ProductHomeMessage>list) {
        if (homePageFooterAdapter != null) {
            homePageFooterAdapter.addData(list);
        }
    }


    /**
    * 首页刷新完成
    * */
    public void homeDataToRefreshEnd() {
        this.setAdapters(adapters);
    }

    /**
    * 移除定时器
    * */
    public void destroyTimer() {
        if (homePageXTimeLimitedHeadAdapter != null) {
            homePageXTimeLimitedHeadAdapter.destroy_timer();
        }
    }


    @Override
    public void adData(String ad_name, String ad_id, String ad_group_name, String ad_group_id, String skip_type, String skip_value, String rank) {

    }

}
